package com.hd.contentmonitor.service;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

import difflib.*;


public class BasicDiff {
    // Helper method for get the file content
    private static List<String> fileToLines(String filename) {
            List<String> lines = new LinkedList<String>();
            String line = "";
            try {
                    BufferedReader in = new BufferedReader(new FileReader(filename));
                    while ((line = in.readLine()) != null) {
                            lines.add(line);
                    }
            } catch (IOException e) {
                    e.printStackTrace();
            }
            return lines;
    }

    public static void main(String[] args) {
            List<String> original = fileToLines("D:\\temp1.html");
            List<String> revised  = fileToLines("D:\\tempold1.html");
            
            // Compute diff. Get the Patch object. Patch is the container for computed deltas.
            Patch patch = DiffUtils.diff(original, revised);

            for (Delta delta: patch.getDeltas()) {
            	System.out.println("printing delta");
                    System.out.println(delta+"\n");
            }
    }
}